//
//  Auction_MainRecommend_Cell_WX.m
//  ZITHER
//
//  Created by weixin on 2019/5/28.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Auction_MainRecommend_Cell_WX.h"

@implementation Auction_MainRecommend_Cell_WX

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self setCornerRadiusWithRadius:8 isMasks:YES];
        [self setUI];
    }
    return self;
}


-(void)setModel:(specialSaleSceneidList *)model{
    _model = model;
    //discount  quoteNum
    
    [self.goodsPic sd_setImage:model.cover];
    self.titleLab.text = model.title;
    
    if (model.priceDiscount.length>0 ) {
        self.PriceLab.text = [NSString stringWithFormat:@"¥%@",model.priceDiscount];
    }else{
        self.PriceLab.text = @"¥ ？？？";
    }
    
    
    [self.loactionBtn setTitle: [NSString stringWithFormat:@"%@%@",model.province,model.city] forState:UIControlStateNormal];
    
    self.HotBtn.hidden = NO;

    if ([model.type isEqualToString:@"QUOTE"]) {
        if (![model.quoteNum isEqualToString:@"0"] && model.quoteNum.length>0) {
            [self.HotBtn setTitle:[NSString stringWithFormat:@" %@",model.quoteNum] forState:UIControlStateNormal];
        }else{
            self.HotBtn.hidden = YES;
        }
    }else{
        if (![model.discount isEqualToString:@"0"] && model.discount.length>0) {
            [self.HotBtn setTitle:[NSString stringWithFormat:@" %@",model.discount] forState:UIControlStateNormal];
        }else{
            self.HotBtn.hidden = YES;
        }
    }
    
    /**
     @property (nonatomic,strong)BaseImageV * goodsPic;
     @property (nonatomic,strong)BaseBtn * loactionBtn;
     @property (nonatomic,strong)BaseBtn * HotBtn;
     @property (nonatomic,strong)BaseLab * titleLab;
     @property (nonatomic,strong)BaseLab * PriceLab;
     @property (nonatomic,strong)BaseLab * titleSubLab;
    */
    
}

-(void)setUI{
    /**
     goodsPic;
     loactionBtn;
     HotBtn;
     titleLab;
     PriceLab;
     */
    
    [self.goodsPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self).offset(0);
        make.top.equalTo(self).offset(0);
        make.height.mas_equalTo(198);
        make.width.mas_equalTo(168);
    }];
    
    [self.loactionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsPic).offset(12);
//      make.right.equalTo(self.goodsPic).offset(-5);
        make.bottom.equalTo(self.goodsPic).offset(-8);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(kScreenW/4.0);
    }];
    
    [self.HotBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.goodsPic).offset(-12);
        make.bottom.equalTo(self.goodsPic).offset(-8);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(50);
    }];
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.goodsPic.mas_bottom).offset(10);
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-5);
    }];
    
    [self.titleSubLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom).offset(10);
        make.left.equalTo(self).offset(10);
        make.width.mas_equalTo(50);
    }];
    
    [self.PriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.titleSubLab).offset(0);
        make.left.equalTo(self.titleSubLab.mas_right).offset(-10);
        make.right.equalTo(self).offset(-5);
    }];

}

/**
 goodsPic;
 loactionBtn;
 HotBtn;
 titleLab;
 PriceLab;
 */

- (BaseImageV *)goodsPic{
    if (!_goodsPic) {
        _goodsPic = [BaseImageV initCustom:CGRectZero contentMode:2];
        _goodsPic.backgroundColor = [UIColor grayColor];
        [self addSubview:_goodsPic];
    }
    return _goodsPic;
}

- (BaseBtn *)loactionBtn{
    if (!_loactionBtn) {
        _loactionBtn = [BaseBtn initCustomBtnImageAndTitles:@[@"广东深圳"] images:@[@"sku_定位"] color:@[HexColor(0xffffff)]];
        [_loactionBtn setImageEdgeInsets:UIEdgeInsetsMake(0,5, 0,-5)];
        [_loactionBtn setTitleEdgeInsets:UIEdgeInsetsMake(0,5, 0,-5)];

        _loactionBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:12];
        UIImage *image =  [[UIImage imageNamed:@"sku_定位"] imageWithColor:[UIColor whiteColor]];
        [_loactionBtn setImage:image forState:UIControlStateNormal];
        _loactionBtn.backgroundColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:0.7];
        _loactionBtn.userInteractionEnabled = NO;
        [self addSubview:_loactionBtn];
    }
    return _loactionBtn;
}

- (BaseBtn *)HotBtn{
    if (!_HotBtn) {
        _HotBtn = [BaseBtn initCustomBtnImageAndTitles:@[@"40"] images:@[@"交易_热度"] color:@[HexColor(0xf6f6f6)]];
        _HotBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
        _HotBtn.userInteractionEnabled = NO;
        _HotBtn.titleLabel.textColor = HexColor(0xf6f6f6);
        _HotBtn.backgroundColor = [UIColor clearColor];
        [self addSubview:_HotBtn];
    }
    return _HotBtn;
}


-(BaseLab *)titleLab{
    if (!_titleLab) {
        _titleLab = [BaseLab initCustomLab:@"介绍介绍介绍123sd112321q" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:12]];
        _titleLab.backgroundColor = [UIColor clearColor];
        _titleLab.numberOfLines = 2;
        [self addSubview:_titleLab];

    }
    return _titleLab;
}


-(BaseLab *)titleSubLab{
    if (!_titleSubLab) {
        _titleSubLab = [BaseLab initCustomLab:@"特卖价" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
        _titleSubLab.backgroundColor = [UIColor clearColor];
        [self addSubview:_titleSubLab];

    }
    return _titleSubLab;
}

-(BaseLab *)PriceLab{
    if (!_PriceLab) {
        _PriceLab = [BaseLab initCustomLab:@"$123123" color:HexColor(0xff6f6f) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:15]];
        _PriceLab.backgroundColor = [UIColor clearColor];
        [self addSubview:_PriceLab];
    }
    return _PriceLab;
}



/**
goodsPic;
loactionBtn;
HotBtn;
titleLab;
PriceLab;
 */

@end
